<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li ><a href="{:url('magic/index')}">魔法召唤奖品列表</a></li>
			<li class="active"><a >{:lang('EDIT')}</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('magic/editPost')}">
            <div class="form-group">
				<label for="input-name" class="col-sm-2 control-label"><span class="form-required">*</span>类型</label>
				<div class="col-md-6 col-sm-10">
					<volist name="allType" id="vo" key="kk">
					<input type="checkbox" name="types[]" value="{$key}" <if condition="in_array($key, $data['types'])">checked</if>>{$vo}</option>
					</volist>
				</div>
			</div>

			<div class="form-group" id="gift">
				<label for="input-name" class="col-sm-2 control-label"><span class="form-required">*</span>礼物</label>
				<div class="col-md-6 col-sm-10">
					<select class="form-control" name="giftid" id="giftid">
						<volist name="gift" id="v">
						<option value="{$v['id']}" data-needcoin="{$v['needcoin']}" <eq name="data['giftid']" value="$v['id']">selected</eq>>{$v['giftname']}</option>
						</volist>
					</select>
				</div>
			</div>

			<div class="form-group" id="needcoin">
				<label for="input-rate" class="col-sm-2 control-label"><span class="form-required">*</span>价格</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-needcoin" name="needcoin" value="{$data['needcoin']}">
				</div>
			</div>

            <div class="form-group" id="rate">
				<label for="input-rate" class="col-sm-2 control-label"><span class="form-required">*</span>中奖比例</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-rate" name="rate" value="{$data['rate']}">% 范围：0.001% - 100% 
				</div>
			</div>
            
            <div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="hidden" name="id" value="{$data.id}" />
                    <input type="hidden" name="thumb_old" value="{$data.thumb}" />
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('EDIT')}</button>
					<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
				</div>
			</div>

		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
    <script type="text/javascript">
        (function(){
            $('.btn-cancel-thumbnail').click(function () {
                $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
                $('#thumbnail').val('');
            });
            
            $("#giftid").change(function(){
                //var needcoin=$(this).data('needcoin');
				//var needcoin= $(this).find("option:selected").attr("data-needcoin");
				var needcoin= $(this).find("option:selected").data("needcoin");
				$('#input-needcoin').val(needcoin);
            })
        })()

    </script>
</body>
</html>